Skip to content

all: replace strings.Replace(_, -1) with strings.ReplaceAll#3697

Open
Deln0r wants to merge 1 commit into
element-hq:mainfrom
Deln0r:lint/qf1004-strings-replaceall
Open

all: replace strings.Replace(_, -1) with strings.ReplaceAll#3697
Deln0r wants to merge 1 commit into
element-hq:mainfrom
Deln0r:lint/qf1004-strings-replaceall

Conversation

@Deln0r
Copy link
Copy Markdown

@Deln0r Deln0r commented May 14, 2026

Summary

staticcheck QF1004 prefers strings.ReplaceAll over strings.Replace with a -1 count: the intent of replace-everywhere is clearer in the name and matches the form added to the standard library in Go 1.12.

Three call sites across two files:

  • internal/pushrules/util.go — glob-to-regex translation (*.*, ?.)
  • syncapi/storage/postgres/filtering.go — glob-to-LIKE translation (*%)

No behavior change.

Test plan

  • go build ./... clean
  • CI lint/test on this PR

staticcheck QF1004 prefers strings.ReplaceAll over strings.Replace
with a -1 count: the intent of replace-everywhere is clearer in the
name and matches the form added to the standard library in Go 1.12.

Three call sites:

- internal/pushrules/util.go: glob-to-regex translation
- syncapi/storage/postgres/filtering.go: glob-to-LIKE translation

No behavior change.

Signed-off-by: Ian Chechin <ian00chechin@gmail.com>
@Deln0r Deln0r requested a review from a team as a code owner May 14, 2026 15:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant